﻿namespace ihongma.Web.Plugin.Feedback.admin
{
    using ihongma.Common;
    using ihongma.Web.Plugin.Feedback.BLL;
    using ihongma.Web.Plugin.Feedback.Model;
    using ihongma.Web.UI;
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class reply : ManagePage
    {
        protected Button btnSubmit;
        protected HtmlForm form1;
        private int id = 0;
        protected mfeedback model = new mfeedback();
        protected TextBox txtReContent;

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
           feedback feedback = new feedback();
            this.model = feedback.GetModel(this.id);
            this.model.reply_content = Utils.ToHtml(this.txtReContent.Text);
            this.model.reply_time = new DateTime?(DateTime.Now);
            feedback.Update(this.model);
            base.JscriptMsg("留言回复成功啦！", "index.aspx", "Success");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!int.TryParse(base.Request.QueryString["id"], out this.id))
            {
                base.JscriptMsg("传输参数不正确！", "back", "Error");
            }
            else if (!new feedback().Exists(this.id))
            {
                base.JscriptMsg("信息不存在或已被删除！", "back", "Error");
            }
            else if (!this.Page.IsPostBack)
            {
                this.ShowInfo(this.id);
            }
        }

        private void ShowInfo(int _id)
        {
            this.model = new feedback().GetModel(_id);
            this.txtReContent.Text = Utils.ToTxt(this.model.reply_content);
        }
    }
}

